package com.nuyoah.entity;

import java.time.LocalDateTime;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.baomidou.mybatisplus.annotation.TableField;
import com.nuyoah.security.AccountUser;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * <p>
 *
 * </p>
 *
 * @author xiaoming
 * @since 2024-03-26
 */
@Data
@EqualsAndHashCode(callSuper = true)
public class User extends BaseEntity{

    private static final long serialVersionUID = 1L;

    private String studentId;

    private String username;

    private String password;

    private String avatar;

    private LocalDateTime lastLogin;

    private String name;


    @TableField(exist = false)
    private List<Role> roles = new ArrayList<>();

    // User.java
    public boolean isAdmin() {
        return this.getRoles().contains("admin");
    }

    public boolean isSuperAdmin() {
        return this.getRoles().contains("superAdmin");
    }

}
